<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">
<title></title>
<script src="../easyui-1.3.5/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
var success1 = function() {
	console.log('success');
	return "success";
}

var fail1 = function() {
	console.log('failed');
	return "failed";
}

var success2 = function(text) {
	console.log(text);
	console.log('second s');
	return $.ajax({
		url: 'jquery-1.9.1.js',
		dataType: 'script'
	});
}

var fail2 = function(text) {
	console.log('second f');
	return $.ajax({
		url: 'jquery-1.9.1.js',
		dataType: 'script'
	});
}

var success3 = function() {
	console.log('success2');
}

var fail3 = function() {
	console.log('failed2');
}

function juqery_deferred_ajax() {
	$.ajax({
		url: 'success.php'
	}).then(success1, fail1).then(success2, fail2).then(success3, fail3);
}

function then() {
	var req1 = $.get('api1/data');
	var req2 = $.get('api2/data');
	var req3 = $.get('api3/data');
	req1.then(function(req1Data) {
		return req2.done(otherFunc);
	}).then(function(req2Data) {
		return req3.done(otherFunc2);
	}).then(function(req3Data) {
		doneSomethingWithReq3();
	});
}

function processResult() {
	$.when($.ajax({
			url: 'success.php'
		}), $.ajax({
			url: '../easyui-1.3.5/jquery.min.js'
		}))
		.then(function(FirstAjaxSuccessCallbackArgs, SecondAjaxSuccessCallbackArgs) {
			console.log('success');
		}, function() {
			console.log('failed');
		});
}

function prepareInterface() {
	return $.Deferred(function(dfd) {
		var latest = $(".news, .reactions");
		latest.slideDown(500, dfd.resolve);
		latest.addClass(“active”);
	}).promise();
}
</script>
</head>

<body>
</body>
<input type="button" value="juqery-deferred-ajax" onclick="juqery_deferred_ajax()" />
<input type="button" value="$.when" onclick="processResult()" />

</html>